Adding To A Dictionary - json
(
37
actions, 23 KB)
0 Text
➔ filename
»
1
11
34
dictionaryexample.json
1 Get File at Path
[0 filename]
from Folder »
FileErrorIfNotFound
:
false
ShowFilePicker
:
false
GetFolderContents
:
true
2 Get Text from
[1 File]
»
3 Set Variable
DictionayExample
to
[2 Text]
4 If
[DictionayExample]
does not have any value
5 Dictionary »
10
6 Ask for Text Input »
AskActionPrompt
:
Key?
7 Set Variable
Key
to
[6 Ask for Input]
8 Ask for Text Input »
AskActionPrompt
:
Value?
9 Set Variable
Value
to
[8 Ask for Input]
10 Set Dictionary Value for
[Key]
to
[Value]
in
[5 Dictionary]
»
11 Save File
[10 Dictionary]
AskWhereToSave
:
false
SaveFileOverwrite
:
true
FileDestinationPath
:
[0 filename]
12 Otherwise ▵
4
13 Comment
/Start new section to show the dictionary
14 Get Dictionary from
[DictionayExample]
»
15
17
15 Get Dictionary
All Keys
in
[14 Dictionary]
»
16 Repeat with Each in
[15 Dictionary Value]
17 Get Dictionary Value for
[Repeat Item]
in
[14 Dictionary]
»
18 Text
[Repeat Item]
:
[17 Dictionary Value]
19 End Repeat with Each »
20 Show Alert
This is your dictionary: Key:Value
[19 Repeat Results]
AlertActionCancelButtonShown
:
false
21 Comment
/End new section to show the dictionary
22 Ask for Text Input »
AskActionPrompt
:
Key?
23 Set Variable
Key
to
[22 Ask for Input]
24 Comment
Check if key already exists
25 Get Dictionary from
[DictionayExample]
»
26
33
26 Get Dictionary
All Keys
in
[25 Dictionary]
»
27 If
[26 Dictionary Value
as Text
]
contains
[Key]
28 Show Alert
This key is already taken.
AlertActionCancelButtonShown
:
false
29 Run Shortcut
Adding To A Dictionary
Workflow
:
{ "workflowName": "Adding To A Dictionary", "isSelf": false }
ShowWorkflow
:
false
30 Otherwise
31 Ask for Text Input »
AskActionPrompt
:
Value?
32 Set Variable
Value
to
[31 Provided Input]
33 Set Dictionary Value for
[Key]
to
[Value]
in
[25 Dictionary]
»
34 Save File
[33 Dictionary]
AskWhereToSave
:
false
SaveFileOverwrite
:
true
FileDestinationPath
:
[0 filename]
35 End If
36 End If ▵
12